<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="inc/connmysql.jsp"%>
<%@ include file="utils/function.jsp"%>

<%
//业务逻辑代码 
String username = toUTF(request.getParameter("inputname"));
String code = toUTF(request.getParameter("inputcode")); //取得输入的密码和用户名 

if("".equals(username)||"".equals(code)){
response.sendRedirect("Login1.jsp");  // 没有输入信息。
}

else{
PreparedStatement psmt=conn.prepareStatement("SELECT * from users where username = ?");
psmt.setString(1,username);  //查询用户信息，认证登录
ResultSet rs = psmt.executeQuery();
while(rs.next()){
String code1 = rs.getString("code");
if (code1.equals(code)){
	response.sendRedirect("identify.jsp");//成功
}
else{
	response.sendRedirect("Login2.jsp");  //用户名或者密码错误。
}
}
}
%>
<%@ include file="inc/connmysql_close.jsp"%>